package com.maker.service;


import com.maker.entity.OrderInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.time.Instant;
import java.util.Date;
import java.util.List;

@Repository
public interface OrderInfoRepository extends JpaRepository<OrderInfo,Long> {
    @Query(value = "from OrderInfo where productId = ?1 and orderStatus = ?2 and userId = ?3")
    public List<OrderInfo> getOrderInfoByProductId(Long productId, String orderStatus, Long userId);

    @Query(value = "from OrderInfo where orderNo = ?1 and userId = ?2" )
    public OrderInfo getOrderInfoByOrderNo(String orderNo,Long userId);
    @Query("from OrderInfo order WHERE order.createTime < :timestamp and order.orderStatus = :orderStatus and order.paymentType = :type")
    public List<OrderInfo> getNoPayOrderByDuration(Date timestamp, String orderStatus, String type);
}
